Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

712
Visualizações
Move this array "sort" operation to a separate statement. angular 10

t get this message : 'Move this array "sort" operation to a separate statement'

if (isDefined(this.#Type.externalControls)){
  this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);
  this.#Type.externalControls.forEach((control: ITypeControl) => {
    externalForm.push(new FormControl(control));
  });
}

please help me to resolve the issue.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

What .sort does is, it sorts the array it's called on in place, and then returns that array. Assigning the return value of .sort to a new variable could well cause confusion, because now you (may) have two references to the same exact (now sorted) array, rather than a reference to a sorted array and a reference to an unsorted array.

That is

const arr = getArr();
const sortedArr = arr.sort();

is confusing, because arr === sortedArr.

The warning is telling you to not use the return value of .sort, to avoid confusing yourself. Change

this.#Type.externalControls = this.#Type.externalControls.sort(sortFn);

to

this.#Type.externalControls.sort(sortFn);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda